From 34daca586771e7237b72fe75ed60387224e2efe0 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 2 Oct 2002 15:23:24 +0000 Subject: [PATCH] More fixes from Alex for csv_util.c --- gpsbabel/csv_util.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/gpsbabel/csv_util.c b/gpsbabel/csv_util.c index 207c74a14..86e0f7c84 100644 --- a/gpsbabel/csv_util.c +++ b/gpsbabel/csv_util.c @@ -44,8 +44,7 @@ csv_stringclean(const char *string, const char *chararray) { } /* p2 - end of the original string */ - p2 = tmp; - while (*p2) p2++; + p2 = tmp + strlen(tmp); cp = chararray; @@ -88,20 +87,16 @@ csv_stringtrim(const char *string, const char *enclosure) elen = strlen(enclosure); } - p2 = tmp; + p2 = tmp + strlen(tmp) - 1; p1 = tmp; - /* advance p2 to the end of the string, then back it off. */ - while ((*p2) && (p2++)) { } - p2--; - /* trim off trailing whitespace */ - while (isspace(*p2)) { + while ((p2 > p1) && isspace(*p2)) { p2--; } /* advance p1 past any leading whitespace */ - while (isspace(*p1)) { + while ((p1 < p2) && (isspace(*p1))) { p1++; } @@ -202,3 +197,4 @@ csv_lineparse(const char *stringstart, const char *delimited_by, return (tmp); } + -- 2.30.2